/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import business.CarDetailBusiness;
import business.FlightBusiness;
import business.HotelsBusiness;
import business.TourBookingBusiness;
import business.TourBusiness;
import java.util.ArrayList;
import model.CarDetails;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import model.Flight;
import model.Hotels;
import model.PackageTour;
import model.TourBooking;
import model.TourBookingDetails;

/**
 *
 * @author Administrator
 */
@ManagedBean
@RequestScoped
public class AdminSearchBean {

    private FlightBusiness flightBusiness = new FlightBusiness();
    private HotelsBusiness hotelsBusiness = new HotelsBusiness();
    private TourBusiness tourbussiness = new TourBusiness();
    private CarDetailBusiness cardetailbuz = new CarDetailBusiness();
    private TourBookingDetails tourBookingDetails = new TourBookingDetails();
    private List<Flight> listFlight = null;
    private List<Hotels> listHotel;
    private List<PackageTour> listPKTour;
    private List<CarDetails> listCarDetail;
    private List<PackageTour> listTourByState;
    private List<TourBooking> listTourBooking;
    private String userNames;
    private String packageNames;
    private List<TourBookingDetails> listTourBookingDetail = new ArrayList<TourBookingDetails>();

    public List<TourBookingDetails> getListTourBookingDetail() {
        return listTourBookingDetail;
    }

    public void setListTourBookingDetail(List<TourBookingDetails> listTourBookingDetail) {
        this.listTourBookingDetail = listTourBookingDetail;
    }

    public String getPackageNames() {
        return packageNames;
    }

    public void setPackageNames(String packageNames) {
        this.packageNames = packageNames;
    }

    public String getUserNames() {
        return userNames;
    }

    public void setUserNames(String userNames) {
        this.userNames = userNames;
    }

    public List<TourBooking> getListTourBooking() {
        return listTourBooking;
    }

    public void setListTourBooking(List<TourBooking> listTourBooking) {
        this.listTourBooking = listTourBooking;
    }

    public List<PackageTour> getListTourByState() {
        return listTourByState;
    }

    public void setListTourByState(List<PackageTour> listTourByState) {
        this.listTourByState = listTourByState;
    }

    public List<CarDetails> getListCarDetail() {
        return listCarDetail;
    }

    public void setListCarDetail(List<CarDetails> listCarDetail) {
        this.listCarDetail = listCarDetail;
    }

    public List<PackageTour> getListPKTour() {
        return listPKTour;
    }

    public void setListPKTour(List<PackageTour> listPKTour) {
        this.listPKTour = listPKTour;
    }

    public List<Hotels> getListHotel() {
        return listHotel;
    }

    public void setListHotel(List<Hotels> listHotel) {
        this.listHotel = listHotel;
    }

    public List<Flight> getListFlight() {
        return listFlight;
    }

    public void setListFlight(List<Flight> listFlight) {
        this.listFlight = listFlight;
    }
    private TourBookingBusiness tbookbusiness = new TourBookingBusiness();

    /** Creates a new instance of AdminSearchBean */
    public AdminSearchBean() {
//        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
        String chooseAction = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("ChooseActionString").toString();
        String content = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("ContentString").toString();
        if (chooseAction.equalsIgnoreCase("Flight by Name")) {
            listFlight = flightBusiness.searchFlightByName(content);
        } else if (chooseAction.equalsIgnoreCase("Hotel by Name")) {
            listHotel = hotelsBusiness.searchHotelByName(content);
        } else if (chooseAction.equalsIgnoreCase("Tour by Name")) {
            listPKTour = tourbussiness.getListSearch(content);
        } else if (chooseAction.equalsIgnoreCase("Car by Name")) {
            listCarDetail = cardetailbuz.getListSearch(content);
        } else if (chooseAction.equalsIgnoreCase("Tour by State")) {
            if (content.equalsIgnoreCase("wait")) {

                listTourByState = tourbussiness.listSearchTourState(0);

            } else if (content.equalsIgnoreCase("active")) {
                // int state =0;
                listTourByState = tourbussiness.listSearchTourState(1);
            }

        } else if (chooseAction.equalsIgnoreCase("TourBooking By UserName")) {

            listTourBooking = tbookbusiness.getListSearchByUser(content);
            for (TourBooking tourBooking : listTourBooking) {
                tourBookingDetails = new TourBookingDetails();
                tourBookingDetails.setTourBooking(tourBooking);
                tourBookingDetails.setUsernames(tbookbusiness.getUserNameFromID(tourBooking.getCustomerID()));
                tourBookingDetails.setPackagenames(tbookbusiness.getPackageNameFromID(tourBooking.getPackageTourID()));
                listTourBookingDetail.add(tourBookingDetails);
            }

        }


    }
}
